﻿'
' Will Strohl (wills@strohlsitedesign.com)
' http://www.willstrohl.com
'
'Copyright (c) 2010, Will Strohl
'All rights reserved.
'
'Redistribution and use in source and binary forms, with or without modification, are 
'permitted provided that the following conditions are met:
'
'Redistributions of source code must retain the above copyright notice, this list of 
'conditions and the following disclaimer.
'
'Redistributions in binary form must reproduce the above copyright notice, this list 
'of conditions and the following disclaimer in the documentation and/or other 
'materials provided with the distribution.
'
'Neither the name of StrohlSiteDesign.com nor the names of its contributors may be 
'used to endorse or promote products derived from this software without specific prior 
'written permission.
'
'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
'EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
'OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
'SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
'TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
'BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
'ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
'DAMAGE.
'

Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Localization

Namespace WillStrohl.Modules.QueryToGrid

    Public MustInherit Class WNSPortalModuleBase
        Inherits PortalModuleBase
        Implements IActionable

#Region " Private Members "

        Private Const LOCAL_RESOURCE_FILE_PATH As String = "/DesktopModules/WillStrohl.QueryToGrid/App_LocalResources/Global.resx"

        Private p_GridSettings As SettingsInfo = Nothing

#End Region

#Region " Properties "

        Protected ReadOnly Property GridSettings() As SettingsInfo
            Get
                If Not Me.p_GridSettings Is Nothing Then
                    Return Me.p_GridSettings
                End If

                Dim ctlModule As New QueryToGridController
                Dim objSettings As New SettingsInfo
                objSettings = ctlModule.GetSettings(Me.ModuleId)

                If Not objSettings Is Nothing Then
                    Me.p_GridSettings = objSettings
                End If

                Return Me.p_GridSettings

            End Get
        End Property

#End Region

#Region " Localization "

        Protected Overloads Function GetLocalizedString(ByVal LocalizationKey As String) As String

            Return Me.GetLocalizedString(LocalizationKey, LOCAL_RESOURCE_FILE_PATH)

        End Function

        Protected Overloads Function GetLocalizedString(ByVal LocalizationKey As String, ByVal LocalResourceFilePath As String) As String

            If String.IsNullOrEmpty(LocalResourceFilePath) Then
                LocalResourceFilePath = LOCAL_RESOURCE_FILE_PATH
            End If

            If Not String.IsNullOrEmpty(LocalizationKey) Then
                Return Localization.GetString(LocalizationKey, LocalResourceFilePath)
            Else
                Return String.Empty
            End If

        End Function

#End Region

        Protected Sub SendTo(ByVal Location As String)
            Try
                Response.Redirect(Location)
            Catch
                ' do nothing
            End Try
        End Sub

#Region " IActionable Implementation "

        Public ReadOnly Property ModuleActions() As DotNetNuke.Entities.Modules.Actions.ModuleActionCollection Implements IActionable.ModuleActions
            Get
                Dim Actions As New Actions.ModuleActionCollection
                Actions.Add(GetNextActionID, Me.GetLocalizedString("Menu.Options.Title"), _
                    String.Empty, String.Empty, String.Empty, _
                    EditUrl(String.Empty, String.Empty, "Options"), _
                    False, DotNetNuke.Security.SecurityAccessLevel.Edit, True, False)
                Return Actions
            End Get
        End Property

#End Region

    End Class

End Namespace